﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WiewProyecto.aspx.cs" Inherits="Proyectos_Seguimiento_WiewProyecto" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Register Src="wucSeguimiento.ascx" TagName="wucSeguimiento" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <ext:Store ID="StoreProgramas" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StoreEstado" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StoreEje" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StoreTipo" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="Key">
                <Fields>
                    <ext:RecordField Name="Value">
                    </ext:RecordField>
                    <ext:RecordField Name="Key">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Store ID="StoreProyectos" runat="server">
        <Reader>
            <ext:JsonReader ReaderID="Id">
                <Fields>
                    <ext:RecordField Name="Id" />
                    <ext:RecordField Name="Nombre" />
                    <ext:RecordField Name="FechaInicio" Type="Date" DateFormat="Y-m-dTh:i:s" />
                    <ext:RecordField Name="FechaFin" Type="Date" DateFormat="Y-m-dTh:i:s" />
                    <ext:RecordField Name="Presupuesto" />
                    <ext:RecordField Name="Latitud" />
                    <ext:RecordField Name="Longitud" />
                    <ext:RecordField Name="Estado" />
                    <ext:RecordField Name="Tipo" />
                    <ext:RecordField Name="Saldo" />
                    <ext:RecordField Name="UltimoPago" />
                    <ext:RecordField Name="Descripcion" />
                    <ext:RecordField Name="AportePlan" />
                    <ext:RecordField Name="PorcentajeAvance" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>

    <script type="text/javascript">
    var columnaRenderer = function(value) {
                var r = <%= this.StoreEstado.ClientID %>.getById(value);

                if (Ext.isEmpty(r)) {
                    return value;
                }

                return r.data['Value'];
            };
            var columnaRendererTipo = function(value) {
                var r = <%= this.StoreTipo.ClientID %>.getById(value);

                if (Ext.isEmpty(r)) {
                    return value;
                }

                return r.data['Value'];
            };;
            
    </script>

    <ext:ScriptManager ID="smPerfiles" runat="server"  Theme="Gray"/>
    <ext:Panel ID="Panel1" BodyStyle="padding:15px;background-color:#E7E4DD;" runat="server"
        AutoHeight="true">
        <Body>
            <ext:Panel ID="Panel2" runat="server" BodyStyle="background-color:Transparent;">
                <Body>
                    <ext:ColumnLayout ID="ColumnLayout1" runat="server">
                        <ext:LayoutColumn ColumnWidth=".33">
                            <ext:Panel ID="Panel3" runat="server" Border="false" Header="false" BodyStyle="padding:10px;background-color:Transparent;">
                                <Body>
                                    <ext:FormLayout ID="FormLayout1" runat="server" LabelAlign="Left" LabelWidth="70">
                                        <ext:Anchor Horizontal="95%">
                                            <ext:ComboBox Editable="false" FieldLabel="Eje" ID="cbxEje" StoreID="StoreEje" runat="server"
                                                DisplayField="Value" ValueField="Key" TypeAhead="true" ForceSelection="true"
                                                TriggerAction="All" Grow="true" GrowMax="300" EmptyText="Todos" SelectOnFocus="true"
                                                AutoDataBind="True">
                                                <Triggers>
                                                    <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                                </Triggers>
                                                <Listeners>
                                                    <Select Handler="this.triggers[0].show();" />
                                                    <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                                    <TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
                                                </Listeners>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                        <ext:Anchor Horizontal="95%">
                                            <ext:ComboBox Editable="false" FieldLabel="Estado" ID="cbxEstado" runat="server"
                                                StoreID="StoreEstado" DisplayField="Value" ValueField="Key" TypeAhead="true"
                                                ForceSelection="true" TriggerAction="All" Grow="true" GrowMax="300" EmptyText="Todos"
                                                SelectOnFocus="true" AutoDataBind="True">
                                                <Triggers>
                                                    <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                                </Triggers>
                                                <Listeners>
                                                    <Select Handler="this.triggers[0].show();" />
                                                    <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                                    <TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
                                                </Listeners>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                    </ext:FormLayout>
                                </Body>
                            </ext:Panel>
                        </ext:LayoutColumn>
                        <ext:LayoutColumn ColumnWidth=".34">
                            <ext:Panel ID="Panel4" Height="70" runat="server" Border="false" BodyStyle="padding:10px;background-color:Transparent;">
                                <Body>
                                    <ext:FormLayout ID="FormLayout2" LabelSeparator=":" runat="server" LabelAlign="Left"
                                        LabelWidth="65">
                                        <ext:Anchor Horizontal="95%">
                                            <ext:ComboBox Editable="false" FieldLabel="Programa" ID="cbxProgramas" runat="server"
                                                StoreID="StoreProgramas" DisplayField="Value" ValueField="Key" TypeAhead="true"
                                                ForceSelection="true" TriggerAction="All" Grow="true" GrowMax="300" EmptyText="Todos"
                                                SelectOnFocus="true" AutoDataBind="True">
                                                <Triggers>
                                                    <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                                </Triggers>
                                                <Listeners>
                                                    <Select Handler="this.triggers[0].show();" />
                                                    <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                                    <TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
                                                </Listeners>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                        <ext:Anchor Horizontal="95%">
                                            <ext:TextField FieldLabel="Nombre" ID="txtNombrePrograma" runat="server" />
                                        </ext:Anchor>
                                    </ext:FormLayout>
                                </Body>
                            </ext:Panel>
                        </ext:LayoutColumn>
                        <ext:LayoutColumn ColumnWidth=".33">
                            <ext:Panel ID="Panel5" Height="70" runat="server" Border="false" BodyStyle="padding:10px;background-color:Transparent;">
                                <Body>
                                    <ext:FormLayout ID="FormLayout3" LabelSeparator=":" runat="server" LabelAlign="Left"
                                        LabelWidth="50">
                                        <ext:Anchor Horizontal="95%">
                                            <ext:ComboBox Editable="false" FieldLabel="Tipo" ID="cbxCategorias" StoreID="StoreTipo"
                                                runat="server" DisplayField="Value" ValueField="Key" TypeAhead="true" ForceSelection="true"
                                                TriggerAction="All" Grow="true" GrowMax="300" EmptyText="Todos" SelectOnFocus="true"
                                                AutoDataBind="True">
                                                <Triggers>
                                                    <ext:FieldTrigger Icon="Clear" HideTrigger="true" />
                                                </Triggers>
                                                <Listeners>
                                                    <Select Handler="this.triggers[0].show();" />
                                                    <BeforeQuery Handler="this.triggers[0][ this.getRawValue().toString().length == 0 ? 'hide' : 'show']();" />
                                                    <TriggerClick Handler="if(index == 0) { this.clearValue(); this.triggers[0].hide(); }" />
                                                </Listeners>
                                            </ext:ComboBox>
                                        </ext:Anchor>
                                    </ext:FormLayout>
                                </Body>
                            </ext:Panel>
                        </ext:LayoutColumn>
                    </ext:ColumnLayout>
                </Body>
            </ext:Panel>
            <ext:Panel ID="Panel6" runat="server" AutoHeight="true" BodyStyle="padding-top:15px;background-color:Transparent;"
                Border="false">
                <Body>
                    <center>
                        <ext:Button runat="server" ID="btnBuscar" Text="Buscar" Icon="Find">
                            <AjaxEvents>
                                <Click OnEvent="btnBuscar_Click">
                                    <EventMask ShowMask="true" />
                                </Click>
                            </AjaxEvents>
                        </ext:Button>
                    </center>
                </Body>
            </ext:Panel>
        </Body>
    </ext:Panel>
    <ext:GridPanel runat="server" Border="false" ID="gpProyecto" StoreID="StoreProyectos"
        Height="380" AutoExpandColumn="Descripcion" EnableColumnHide="false" StripeRows="true"
        TrackMouseOver="true" Title="Listado de Proyectos">
        <ColumnModel ID="clmBuscarPerfilProyecto" runat="server">
            <Columns>
                <ext:Column ColumnID="NombreProyecto" Header="Proyecto" Width="200" DataIndex="Nombre" />
                <ext:Column DataIndex="Tipo" Header="Tipo" Width="100">
                    <Renderer Fn="columnaRendererTipo" />
                </ext:Column>
                <ext:Column DataIndex="Estado" Header="Estado" Width="100">
                    <Renderer Fn="columnaRenderer" />
                </ext:Column>
                <ext:Column ColumnID="Descripcion" Header="Descripcion" Width="150" DataIndex="Descripcion">
                </ext:Column>
                <ext:Column Header="Saldo por desembolsar" Width="140" DataIndex="Saldo">
                    <Renderer Format="UsMoney" />
                </ext:Column>
                <ext:Column Header="Ultimo Pago" Width="140" DataIndex="UltimoPago">
                    <Renderer Format="UsMoney" />
                </ext:Column>
                <ext:Column Header="Avance" Width="160" Sortable="true" DataIndex="PorcentajeAvance">
                    <Renderer Handler="return record.data.PorcentajeAvance+'%';" />
                </ext:Column>
                <ext:CommandColumn Width="40">
                    <Commands>
                        <ext:GridCommand ToolTip-Text="Seguimiento del Proyecto" Icon="PageEdit" CommandName="Editar">
                        </ext:GridCommand>
                    </Commands>
                </ext:CommandColumn>                
            </Columns>
        </ColumnModel>
        <LoadMask ShowMask="true" />
        <SaveMask ShowMask="true" />
        <Listeners>
            <Command Handler="if(command=='Editar'){if(record.data.Viabilidad=='NO'){alert('El proyecto actual aun no tiene Viabilidad Tecnica');return false;}if(record.data.Dictamen=='NO'){alert('El proyecto actual aun no tiene Dictamen de prioridad');return false;}}" />
        </Listeners>
        <AjaxEvents>
            <Command OnEvent="Editar_Click">
                <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{gpProyecto}.body}" />
                <ExtraParams>
                    <ext:Parameter Name="id" Value="record.data.Id" Mode="Raw" />
                </ExtraParams>
            </Command>
        </AjaxEvents>
        <SelectionModel>
            <ext:RowSelectionModel ID="rsmProyecto" runat="server" />
        </SelectionModel>
        <View>
            <ext:GridView ID="GridView1" runat="server" ForceFit="true" />
        </View>
        <Plugins>
            <ext:RowExpander ID="RowExpander1" runat="server" Collapsed="true">
                <Template ID="Template1" runat="server">
                        <p><b>Proyecto:</b> {Nombre}</p><br/> 
                        <p><b>Descripci&oacute;n:</b> {Descripcion}</p> 
                </Template>
            </ext:RowExpander>
        </Plugins>
        <BottomBar>
            <ext:PagingToolbar ID="ptbProyecto" runat="server" StoreID="StoreProyectos" DisplayInfo="true"
                DisplayMsg="Proyectos {0} - {1} de {2}" EmptyMsg="No existen Proyectos" />
        </BottomBar>
    </ext:GridPanel>
    <uc1:wucSeguimiento runat="server" ID="wucSeguimiento1" />
    </form>
</body>
</html>
